#ifndef _AUTHENTICATION_H_
#define _AUTHENTICATION_H_

#include <string>
#include <packet/IQ.h>

/**
 * Authentication packet, which can be used to login to a XMPP server as well
 * as discover login information from the server.
 */
class Authentication : public IQ {
public:
	
    /**
     * Create a new authentication packet. By default, the packet will be in
     * "set" mode in order to perform an actual authentication with the server.
     * In order to send a "get" request to get the available authentication
     * modes back from the server, change the type of the IQ packet to "get":
     * <p/>
     * <p><tt>setType(IQ.Type.GET);</tt>
     */
    Authentication(); 

    /**
     * Returns the username, or <tt>null</tt> if the username hasn't been sent.
     *
     * @return the username.
     */
	std::string getUsername() {
        return username;
    }
	
    /**
     * Sets the username.
     *
     * @param username the username.
     */
    void setUsername(std::string & username) {
		this->username = username;
	}
	
    /**
     * Returns the plain text password or <tt>null</tt> if the password hasn't
     * been set.
     *
     * @return the password.
     */
	std::string getPassword() {
        return password;
    }
	
    /**
     * Sets the plain text password.
     *
     * @param password the password.
     */
    void setPassword(std::string & password) {
        this->password = password;
    }

    /**
     * Returns the password digest or <tt>null</tt> if the digest hasn't
     * been set. Password digests offer a more secure alternative for
     * authentication compared to plain text. The digest is the hex-encoded
     * SHA-1 hash of the connection ID plus the user's password. If the
     * digest and password are set, digest authentication will be used. If
     * only one value is set, the respective authentication mode will be used.
     *
     * @return the digest of the user's password.
     */
	std::string getDigest() {
        return digest;
    }
	
    /**
     * Sets the digest value using a connection ID and password. Password
     * digests offer a more secure alternative for authentication compared to
     * plain text. The digest is the hex-encoded SHA-1 hash of the connection ID
     * plus the user's password. If the digest and password are set, digest
     * authentication will be used. If only one value is set, the respective
     * authentication mode will be used.
     *
     * @param connectionID the connection ID.
     * @param password     the password.
     * @see org.jivesoftware.smack.XMPPConnection#getConnectionID()
     */
    void setDigest(std::string & connectionID, std::string & password) ;

    /**
     * Sets the digest value directly. Password digests offer a more secure
     * alternative for authentication compared to plain text. The digest is
     * the hex-encoded SHA-1 hash of the connection ID plus the user's password.
     * If the digest and password are set, digest authentication will be used.
     * If only one value is set, the respective authentication mode will be used.
     *
     * @param digest the digest, which is the SHA-1 hash of the connection ID
     *               the user's password, encoded as hex.
     * @see org.jivesoftware.smack.XMPPConnection#getConnectionID()
     */
    void setDigest(std::string & digest) {
        this->digest = digest;
    }

    /**
     * Returns the resource or <tt>null</tt> if the resource hasn't been set.
     *
     * @return the resource.
     */
	std::string getResource() {
        return resource;
    }

    /**
     * Sets the resource.
     *
     * @param resource the resource.
     */
    void setResource(std::string & resource) {
        this->resource = resource;
    }
	
	std::string getChildElementXML() ;
	


private:
	std::string username ;
	std::string password ;
	std::string digest ;
	std::string resource ;

};
#endif // -- _AUTHENTICATION_H_
